local json = require "json"

local file = io.open("./GameList.json", "r");
local content = file:read("*all");
file:close();


local t = json.decode(content)



content = "local t = {\n"
local function dump(t, prefix)
	for k,v in pairs(t) do
		-- print(prefix .. "--" ..type(k) .." -> " .. type(v))
		local k2 = ""
		if type(k) == "number" then
			if k > #t then						
				k2 = '['..k..'] = '
			end
		elseif string.match(k, '%d+') then
			k2 = '["'..k..'"] ='
		else
			k2 = k .. ' = '
		end;


		if type(v) == "string" then
			content = content .. prefix .. k2 .. '"' .. tostring(v) .. '",\n'			
		elseif type(v) == "table" then
			content = content ..prefix .. k2 .. '{\n'
			dump(v, prefix .. "    ")
			content = content ..prefix .. '},\n'
		else
			content = content ..prefix .. k2 .. tostring(v).. ',\n'
		end
	end
end;

dump(t, "    ")
content = content .. "}"

print(content)

